package com.yellowpage.client.action;
  
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.struts2.ServletActionContext;

import com.yellowpage.client.data.UserInfo;
import com.yellowpage.client.service.UserInfoService;
import com.yellowpage.white.common.Configuration;
import com.yellowpage.white.struts.BaseAction;

public class UserInfoAction extends BaseAction {

    public String RESULT_QUERY = "query";
    public String RESULT_ADD = "add";
	public String RESULT_EDIT = "edit";
	
	private Configuration configuration;
	
	public void setConfiguration(Configuration configuration) {
		this.configuration = configuration;
	}
	
	private List<UserInfo> userInfoList = new ArrayList<UserInfo>();
	private List<Map> resultList = new ArrayList<Map>();
	
	private UserInfo userInfo;
	private UserInfoService userInfoService;
	
	private String selectedId;	
	private String[] selectedIds;	
	private String message;
	
		private String query_muid;
		private String query_custId;
		private String query_username;
		private String query_esn;
		private String query_phoneCateg;
		private String query_phone;
		private String query_imsi;
		private String query_classid;
		private String query_levelId;
		private String query_telphone;
		private String query_email;
		private String query_sex;
		private String query_birthday;
		private String query_pno;
		private String query_province;
		private String query_city;
		private String query_district;
		private String query_adress;
		private String query_addChannel;
		private String query_addTime;
		private String query_addTimeend;
		private String query_telIntegral;
		private String query_slIntegral;
		private String query_balance;
		private String query_lastLogin;
		private String query_lastLoginend;
		private String query_lastIp;
		private String query_seqno;
		private String query_macKey;
		private String query_certificatetype;
		private String query_certificatecode;
		private String query_field1;
		private String query_field2;
		private String query_field3;
		private String query_name;
		private String query_id;
		private String query_type;
		private String query_version;
		private String query_password;
		private String query_status;
		private String todownload;
		
	public void prepare() {
		super.prepare();
	
		if (this.selectedId != null && !this.selectedId.equals("")) {
			this.userInfo = userInfoService.getUserInfo(Long.parseLong(selectedId));
		}
	}
	
	public String queryByPage() {		
		initPageRender();
		
		Map queryMap = new HashMap();	
			    queryMap.put("muid", query_muid);
	    	    queryMap.put("custId", query_custId);
	    	    queryMap.put("username", query_username);
	    	    queryMap.put("esn", query_esn);
	    	    queryMap.put("phoneCateg", query_phoneCateg);
	    	    queryMap.put("phone", query_phone);
	    	    queryMap.put("imsi", query_imsi);
	    	    queryMap.put("classid", query_classid);
	    	    queryMap.put("levelId", query_levelId);
	    	    queryMap.put("telphone", query_telphone);
	    	    queryMap.put("email", query_email);
	    	    queryMap.put("sex", query_sex);
	    	    queryMap.put("birthday", query_birthday);
	    	    queryMap.put("pno", query_pno);
	    	    queryMap.put("province", query_province);
	    	    queryMap.put("city", query_city);
	    	    queryMap.put("district", query_district);
	    	    queryMap.put("adress", query_adress);
	    	    queryMap.put("addChannel", query_addChannel);
	    	    queryMap.put("addTime", query_addTime);
	    	    queryMap.put("addTimeend", query_addTimeend);
	    	    queryMap.put("telIntegral", query_telIntegral);
	    	    queryMap.put("slIntegral", query_slIntegral);
	    	    queryMap.put("balance", query_balance);
	    	    queryMap.put("lastLogin", query_lastLogin);
	    	    queryMap.put("lastLoginend", query_lastLoginend);
	    	    queryMap.put("lastIp", query_lastIp);
	    	    queryMap.put("seqno", query_seqno);
	    	    queryMap.put("macKey", query_macKey);
	    	    queryMap.put("certificatetype", query_certificatetype);
	    	    queryMap.put("certificatecode", query_certificatecode);
	    	    queryMap.put("field1", query_field1);
	    	    queryMap.put("field2", query_field2);
	    	    queryMap.put("field3", query_field3);
	    	    
	    	    
	    	    queryMap.put("id", query_id);
	    	    queryMap.put("type", query_type);
	    	    queryMap.put("version", query_version);
	    	    queryMap.put("password", query_password);
	    	    queryMap.put("status", query_status);
	    	    
	    	    queryMap.put("name", query_name);
	    	    /*
	    	    try{		    	        	    
		    	    queryMap.put("name", new String( query_name.getBytes("UTF-8"), "CP1252"));
	    	    }catch(Exception e){
	    	    	e.printStackTrace();
	    	    }*/
	    	    	
		resultList = userInfoService.queryUserInfoByPage(queryMap, pageRender);
		
		setPageRenderToRequest();

		return RESULT_QUERY;
	}
	public String exportExcel() {	

		List<File> srcfile=new ArrayList<File>();  
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType( "text/html;charset=GBK "); 
		String path = request.getSession().getServletContext().getRealPath("");
		path = path.replace("\\","//");
		FileOutputStream fos=null;
		String folder="/UserInfo";
		 File file = new File(path+folder);  
		        if(!file.exists()){  
		            file.mkdir();  
		        }  
				
			try {

			/**
			 * UserInfo导出 
			 */
			boolean UserInfoisnull = false;

			Map queryMap = new HashMap();
			
			 queryMap.put("custId", query_custId);
			    queryMap.put("username", query_username);
			    queryMap.put("phone", query_phone);
			    queryMap.put("telphone", query_telphone);
			    queryMap.put("email", query_email);
			    queryMap.put("sex", query_sex);
			    queryMap.put("birthday", query_birthday);
			    queryMap.put("pno", query_pno);
			    queryMap.put("city", query_city);
			    queryMap.put("adress", query_adress);
	    	    queryMap.put("addChannel", query_addChannel);
	    	    queryMap.put("addTime", query_addTime);
	    	    queryMap.put("addTimeend", query_addTimeend);
			    queryMap.put("lastLogin", query_lastLogin);
			    queryMap.put("lastLoginend", query_lastLoginend);
			    queryMap.put("lastIp", query_lastIp);
			    queryMap.put("seqno", query_seqno);
			    queryMap.put("certificatetype", query_certificatetype);
			    queryMap.put("certificatecode", query_certificatecode);
			    queryMap.put("status", query_status);	    
			    queryMap.put("name", query_name);
				resultList = userInfoService.userInfoServiceexcel(queryMap);		
				int resultListsize=resultList.size();		
				int count = (int) Math.ceil((resultListsize / 1000) + 1);
                int k=0;	
                int i;
                int j=1;
			for(int l=1;l<=count;l++){
				fos = new FileOutputStream(path + folder + "\\UserInfo"+j+".xls");
				HSSFWorkbook workbook = new HSSFWorkbook();
				HSSFSheet sheet = workbook.createSheet("UserInfo");
				sheet.setDefaultColumnWidth(15);
				HSSFRow row = sheet.createRow(0);			 
				row.createCell(0).setCellValue("客户编号 ");	
				row.createCell(1).setCellValue("姓名 ");
				row.createCell(2).setCellValue("用户名 ");
				row.createCell(3).setCellValue("状态 ");
				row.createCell(4).setCellValue("性别 ");
				row.createCell(5).setCellValue("身份证号 ");
				row.createCell(6).setCellValue("手机 ");
				row.createCell(7).setCellValue("电话 ");
				row.createCell(8).setCellValue("邮箱 ");
				row.createCell(9).setCellValue("城市 ");
				row.createCell(10).setCellValue("地址 ");
				row.createCell(11).setCellValue("序列号 ");
				row.createCell(12).setCellValue("证书状态 ");
				row.createCell(13).setCellValue("证书代码 ");
				row.createCell(14).setCellValue("最近登录时间 ");
				row.createCell(15).setCellValue("最近登录IP ");
				row.createCell(16).setCellValue("用户注册时间 ");
				row.createCell(17).setCellValue("新增渠道 ");
			int r=0;
			for ( i = k; i < resultList.size()&&i<k+1000; i++,r++) {					
				HSSFRow data_row = sheet.createRow(r+1);			
			   Map result = (Map)resultList.get(i);	 		 
			   data_row.createCell(0).setCellValue(result.get("CUST_ID")!=null?result.get("CUST_ID").toString():"");					
				data_row.createCell(1).setCellValue(result.get("NAME")!=null?result.get("NAME").toString():"");
				data_row.createCell(2).setCellValue(result.get("USERNAME")!=null?result.get("USERNAME").toString():"");
				data_row.createCell(3).setCellValue(result.get("STATUS")!=null?result.get("STATUS").toString():"");
				data_row.createCell(4).setCellValue(result.get("SEX")!=null?result.get("SEX").toString():"");
				data_row.createCell(5).setCellValue(result.get("PNO")!=null?result.get("PNO").toString():"");
				data_row.createCell(6).setCellValue(result.get("PHONE")!=null?result.get("PHONE").toString():"");						
				data_row.createCell(7).setCellValue(result.get("TELPHONE")!=null?result.get("TELPHONE").toString():"");
				data_row.createCell(8).setCellValue(result.get("EMAIL")!=null?result.get("EMAIL").toString():"");
				data_row.createCell(9).setCellValue(result.get("CITY")!=null?result.get("CITY").toString():"");			
				data_row.createCell(10).setCellValue(result.get("ADRESS")!=null?result.get("ADRESS").toString():"");		
				data_row.createCell(11).setCellValue(result.get("SEQNO")!=null?result.get("SEQNO").toString():"");
				data_row.createCell(12).setCellValue(result.get("CERTIFICATETYPE")!=null?result.get("CERTIFICATETYPE").toString():"");
				data_row.createCell(13).setCellValue(result.get("CERTIFICATECODE")!=null?result.get("CERTIFICATECODE").toString():"");
				data_row.createCell(14).setCellValue(result.get("LAST_LOGIN")!=null?result.get("LAST_LOGIN").toString():"");
				data_row.createCell(15).setCellValue(result.get("LAST_IP")!=null?result.get("LAST_IP").toString():"");
				data_row.createCell(16).setCellValue(result.get("ADD_TIME")!=null?result.get("ADD_TIME").toString():"");
				data_row.createCell(17).setCellValue(result.get("ADD_CHANNEL")!=null?result.get("ADD_CHANNEL").toString():"");
				
				}
				workbook.write(fos);
				srcfile.add(new File(path + folder + "\\UserInfo"+j+".xls"));
				k=k+1000;
				j++;
				response.flushBuffer();
				fos.close();
			}		
				this.addActionMessage("导出UserInfo完成");
			
			
				todownload = "";
				File zipfile = new File(path + folder + ".zip");
				this.zipFiles(srcfile, zipfile);
				todownload = "window.open('UserInfo.zip');";
		
		} catch (Exception e) {
				log.error(e.getMessage(), e);
				this.addActionError("** 生成文件错误 !");
				
			} finally {
				if (fos != null) {
					try {
						//outp.close();
						fos.close();

					} catch (IOException e) {
						log.error(e.getMessage(), e);
					}
				}
			}	
			
			return RESULT_QUERY;
		}	
	
	
	
	public void zipFiles(List<File> srcfile, File zipfile) {  
        byte[] buf = new byte[1024];  
        try {  
            // Create the ZIP file  
            ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipfile));  
            // Compress the files  
            for (int i = 0; i < srcfile.size(); i++) {  
                File file = srcfile.get(i);  
                FileInputStream in = new FileInputStream(file);  
                // Add ZIP entry to output stream.  
                out.putNextEntry(new ZipEntry(file.getName()));  
                // Transfer bytes from the file to the ZIP file  
                int len;  
                while ((len = in.read(buf)) > 0) {  
                    out.write(buf, 0, len);  
                }  
                // Complete the entry  
                out.closeEntry();  
                in.close();  
            }  
            // Complete the ZIP file  
            out.close(); 
        } catch (IOException e) {  
           e.printStackTrace();
        }  
    }  
	
	public String downloadexcel(){
		HttpServletRequest request = ServletActionContext.getRequest();
		HttpServletResponse response = ServletActionContext.getResponse();
		response.setContentType("text/html;charset=GBK ");
		String path = request.getSession().getServletContext().getRealPath("");
		path = path.replace("\\", "//");
		String folder = "//UserInfo";
		File file = new File(path + "\\UserInfo.zip");
		File file2 = new File(path + folder);
		todownload = "";
		if (file.exists()) {
			todownload = "window.open('UserInfo.zip');";
		} else {
			todownload = "";
			message = "请先导出excel数据！";
		}
		todownload = "";
		file.delete();

		if (file2.exists() && file2.isDirectory()) {
			if (file2.listFiles().length == 0) {
				file2.delete();
			} else {
				File delFile[] = file2.listFiles();
				int i = file2.listFiles().length;
				for (int j = 0; j < i; j++) {
					if (delFile[j].isDirectory()) {
						del(delFile[j].getAbsolutePath());
					}
					delFile[j].delete();
				}
			}
		} 		
		return RESULT_QUERY;
	}
	
	private void del(String absolutePath) {
		// TODO Auto-generated method stub
		
	}

	public String toAdd() {
		return RESULT_ADD;
	}
	
	public String save() {
	    
		userInfoService.saveUserInfo(userInfo);		
		
		message = "新增成功!";
		return RESULT_ADD;
	}
	
	public void validateSave() {
		if (userInfo.getCustId().length() == 0) {
			this.addActionError("** 客户编号 不能为空 !");
		}
		if (userInfo.getUsername().length() == 0) {
			this.addActionError("** 用户名 不能为空 !");
		}
		if (userInfo.getPhone().length() == 0) {
			this.addActionError("** 手机 不能为空 !");
		}
		if (userInfo.getTelphone().length() == 0) {
			this.addActionError("** 电话 不能为空 !");
		}
		if (userInfo.getEmail().length() == 0) {
			this.addActionError("** 邮箱 不能为空 !");
		}
		if (userInfo.getSex().length() == 0) {
			this.addActionError("** 性别 不能为空 !");
		}
		if (userInfo.getPno().length() == 0) {
			this.addActionError("** 身份证号码 不能为空 !");
		}
		if (userInfo.getCity().length() == 0) {
			this.addActionError("** 城市 不能为空 !");
		}
		if (userInfo.getAdress().length() == 0) {
			this.addActionError("** 地址 不能为空 !");
		}
		if (userInfo.getSeqno().length() == 0) {
			this.addActionError("** 序列号 不能为空 !");
		}
		if (userInfo.getCertificatetype().length() == 0) {
			this.addActionError("** 证书类型 不能为空 !");
		}
		if (userInfo.getCertificatecode().length() == 0) {
			this.addActionError("** 证书代码 不能为空 !");
		}
		if (userInfo.getName().length() == 0) {
			this.addActionError("** 姓名 不能为空 !");
		}
		if (userInfo.getStatus().length() == 0) {
			this.addActionError("** 状态 不能为空 !");
		}

		this.setValidatorResult("/client/UserInfoAdd.jsp");
	}

	public String toEdit() {
	    Long id = new Long(selectedId);
	    System.out.print(id);
	    userInfo = userInfoService.getUserInfo(id);
	
		return RESULT_EDIT;
	}
	
	public String update() {
	
	    userInfoService.updateUserInfo(userInfo);	

		message = "修改成功!";
	    
		return RESULT_EDIT;
	}
	
	public void validateUpdate() {

		if (userInfo.getCustId().length() == 0) {
			this.addActionError("** 客户编号 不能为空 !");
		}
		if (userInfo.getUsername().length() == 0) {
			this.addActionError("** 用户名 不能为空 !");
		}
		if (userInfo.getPhone().length() == 0) {
			this.addActionError("** 手机 不能为空 !");
		}
		if (userInfo.getTelphone().length() == 0) {
			this.addActionError("** 电话 不能为空 !");
		}
		if (userInfo.getEmail().length() == 0) {
			this.addActionError("** 邮箱 不能为空 !");
		}
		if (userInfo.getSex().length() == 0) {
			this.addActionError("** 性别 不能为空 !");
		}
		if (userInfo.getPno().length() == 0) {
			this.addActionError("** 身份证号码 不能为空 !");
		}
		if (userInfo.getCity().length() == 0) {
			this.addActionError("** 城市 不能为空 !");
		}
		if (userInfo.getAdress().length() == 0) {
			this.addActionError("** 地址 不能为空 !");
		}
		if (userInfo.getSeqno().length() == 0) {
			this.addActionError("** 序列号 不能为空 !");
		}
		if (userInfo.getCertificatetype().length() == 0) {
			this.addActionError("** 证书类型 不能为空 !");
		}
		if (userInfo.getCertificatecode().length() == 0) {
			this.addActionError("** 证书代码 不能为空 !");
		}
		if (userInfo.getName().length() == 0) {
			this.addActionError("** 姓名 不能为空 !");
		}
		if (userInfo.getStatus().length() == 0) {
			this.addActionError("** 状态 不能为空 !");
		}
		this.setValidatorResult("/client/UserInfoUpdate.jsp");
	}
	
	public String delete() {	    
	    List ids = new ArrayList();
	    
		for(String id : selectedIds){
			ids.add(Long.valueOf(id));
		}
		
		try {
			this.userInfoService.delete(ids);
		} catch (Exception e) {
			System.out.println("异常....");
			this.addActionError("** 可能含有子记录约束冲突，删除失败 !");
		}
		
		message = "删除成功!";
		return queryByPage();
	}	
	
	

	/**
	 * getters and setters
	 * 
	 * @return
	 */
	 public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}
	
	public UserInfo getUserInfo() {
		return userInfo;
	}
	 
	 
	 public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}
	
	public List<UserInfo> getUserInfoList() {
		return userInfoList;
	}

	public void setUserInfoList(List<UserInfo> userInfoList) {
		this.userInfoList = userInfoList;
	}
	
	public String getSelectedId() {
		return selectedId;
	}

	public void setSelectedId(String selectedId) {
		this.selectedId = selectedId;
	}

	public String[] getSelectedIds() {
		return selectedIds;
	}

	public void setSelectedIds(String[] selectedIds) {
		this.selectedIds = selectedIds;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
	
	public List<Map> getResultList() {
		return resultList;
	}

	public void setResultList(List<Map> resultList) {
		this.resultList = resultList;
	}
	
	    public String getQuery_muid() {
        return this.query_muid;
    }
    
    public void setQuery_muid(String muid){
        this.query_muid = muid;
    }    

        public String getQuery_custId() {
        return this.query_custId;
    }
    
    public void setQuery_custId(String custId){
        this.query_custId = custId;
    }    

        public String getQuery_username() {
        return this.query_username;
    }
    
    public void setQuery_username(String username){
        this.query_username = username;
    }    

        public String getQuery_esn() {
        return this.query_esn;
    }
    
    public void setQuery_esn(String esn){
        this.query_esn = esn;
    }    

        public String getQuery_phoneCateg() {
        return this.query_phoneCateg;
    }
    
    public void setQuery_phoneCateg(String phoneCateg){
        this.query_phoneCateg = phoneCateg;
    }    

        public String getQuery_phone() {
        return this.query_phone;
    }
    
    public void setQuery_phone(String phone){
        this.query_phone = phone;
    }    

        public String getQuery_imsi() {
        return this.query_imsi;
    }
    
    public void setQuery_imsi(String imsi){
        this.query_imsi = imsi;
    }    

        public String getQuery_classid() {
        return this.query_classid;
    }
    
    public void setQuery_classid(String classid){
        this.query_classid = classid;
    }    

        public String getQuery_levelId() {
        return this.query_levelId;
    }
    
    public void setQuery_levelId(String levelId){
        this.query_levelId = levelId;
    }    

        public String getQuery_telphone() {
        return this.query_telphone;
    }
    
    public void setQuery_telphone(String telphone){
        this.query_telphone = telphone;
    }    

        public String getQuery_email() {
        return this.query_email;
    }
    
    public void setQuery_email(String email){
        this.query_email = email;
    }    

        public String getQuery_sex() {
        return this.query_sex;
    }
    
    public void setQuery_sex(String sex){
        this.query_sex = sex;
    }    

        public String getQuery_birthday() {
        return this.query_birthday;
    }
    
    public void setQuery_birthday(String birthday){
        this.query_birthday = birthday;
    }    

        public String getQuery_pno() {
        return this.query_pno;
    }
    
    public void setQuery_pno(String pno){
        this.query_pno = pno;
    }    

        public String getQuery_province() {
        return this.query_province;
    }
    
    public void setQuery_province(String province){
        this.query_province = province;
    }    

        public String getQuery_city() {
        return this.query_city;
    }
    
    public void setQuery_city(String city){
        this.query_city = city;
    }    

        public String getQuery_district() {
        return this.query_district;
    }
    
    public void setQuery_district(String district){
        this.query_district = district;
    }    

        public String getQuery_adress() {
        return this.query_adress;
    }
    
    public void setQuery_adress(String adress){
        this.query_adress = adress;
    }    

        public String getQuery_addChannel() {
        return this.query_addChannel;
    }
    
    public void setQuery_addChannel(String addChannel){
        this.query_addChannel = addChannel;
    }    

        public String getQuery_addTime() {
        return this.query_addTime;
    }
    
    public void setQuery_addTime(String addTime){
        this.query_addTime = addTime;
    }    

        public String getQuery_telIntegral() {
        return this.query_telIntegral;
    }
    
    public void setQuery_telIntegral(String telIntegral){
        this.query_telIntegral = telIntegral;
    }    

        public String getQuery_slIntegral() {
        return this.query_slIntegral;
    }
    
    public void setQuery_slIntegral(String slIntegral){
        this.query_slIntegral = slIntegral;
    }    

        public String getQuery_balance() {
        return this.query_balance;
    }
    
    public void setQuery_balance(String balance){
        this.query_balance = balance;
    }    

        public String getQuery_lastLogin() {
        return this.query_lastLogin;
    }
    
    public void setQuery_lastLogin(String lastLogin){
        this.query_lastLogin = lastLogin;
    }    

        public String getQuery_lastIp() {
        return this.query_lastIp;
    }
    
    public void setQuery_lastIp(String lastIp){
        this.query_lastIp = lastIp;
    }    

        public String getQuery_seqno() {
        return this.query_seqno;
    }
    
    public void setQuery_seqno(String seqno){
        this.query_seqno = seqno;
    }    

        public String getQuery_macKey() {
        return this.query_macKey;
    }
    
    public void setQuery_macKey(String macKey){
        this.query_macKey = macKey;
    }    

        public String getQuery_certificatetype() {
        return this.query_certificatetype;
    }
    
    public void setQuery_certificatetype(String certificatetype){
        this.query_certificatetype = certificatetype;
    }    

        public String getQuery_certificatecode() {
        return this.query_certificatecode;
    }
    
    public void setQuery_certificatecode(String certificatecode){
        this.query_certificatecode = certificatecode;
    }    

        public String getQuery_field1() {
        return this.query_field1;
    }
    
    public void setQuery_field1(String field1){
        this.query_field1 = field1;
    }    

        public String getQuery_field2() {
        return this.query_field2;
    }
    
    public void setQuery_field2(String field2){
        this.query_field2 = field2;
    }    

        public String getQuery_field3() {
        return this.query_field3;
    }
    
    public void setQuery_field3(String field3){
        this.query_field3 = field3;
    }    

        public String getQuery_name() {
        return this.query_name;
    }
    
    public void setQuery_name(String name){
        this.query_name = name;
    }    

        public String getQuery_id() {
        return this.query_id;
    }
    
    public void setQuery_id(String id){
        this.query_id = id;
    }    

        public String getQuery_type() {
        return this.query_type;
    }
    
    public void setQuery_type(String type){
        this.query_type = type;
    }    

        public String getQuery_version() {
        return this.query_version;
    }
    
    public void setQuery_version(String version){
        this.query_version = version;
    }    

        public String getQuery_password() {
        return this.query_password;
    }
    
    public void setQuery_password(String password){
        this.query_password = password;
    }    

        public String getQuery_status() {
        return this.query_status;
    }
    
    public void setQuery_status(String status){
        this.query_status = status;
    }    
    
    
    public String getQuery_lastLoginend() {
		return query_lastLoginend;
	}

	public void setQuery_lastLoginend(String query_lastLoginend) {
		this.query_lastLoginend = query_lastLoginend;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public String getTodownload() {
		return todownload;
	}

	public void setTodownload(String todownload) {
		this.todownload = todownload;
	}

	public String getQuery_addTimeend() {
		return query_addTimeend;
	}

	public void setQuery_addTimeend(String query_addTimeend) {
		this.query_addTimeend = query_addTimeend;
	}

	public String convertCharset(String s)
    {
        if (s != null)
        {
            try
            {
                int length = s.length();
                byte[] buffer = new byte[length];
                //0x81 to Unicode 0x0081, 0x8d to 0x008d, 0x8f to 0x008f, 0x90 to 0x0090, and 0x9d to 0x009d.
                for (int i = 0; i < length; ++i)
                {
                    char c = s.charAt(i);
                    if (c == 0x0081)
                    {
                        buffer[i] = (byte) 0x81;
                    }
                    else if (c == 0x008d)
                    {
                        buffer[i] = (byte) 0x8d;
                    }
                    else if (c == 0x008f)
                    {
                        buffer[i] = (byte) 0x8f;
                    }
                    else if (c == 0x0090)
                    {
                        buffer[i] = (byte) 0x90;
                    }
                    else if (c == 0x009d)
                    {
                        buffer[i] = (byte) 0x9d;
                    }
                    else
                    {
                        buffer[i] = Character.toString(c).getBytes("CP1252")[0];
                    }
                }
                String result = new String(buffer, "UTF-8");
                return result;
            }
            catch (UnsupportedEncodingException e)
            {
                e.printStackTrace();
            }
        }
        return null;
    }

    
	
}
